package com.github.zhijieqing.socket.cluster.websocket;

import com.github.zhijieqing.common.web.utils.SpringContextUtils;
import com.github.zhijieqing.socket.cluster.common.domain.SocketMsg;
import org.springframework.messaging.simp.SimpMessagingTemplate;

public class WebSocketUtils {

    private static SimpMessagingTemplate template;

    public static SimpMessagingTemplate getTemplate() {
        if(template==null){
            template= SpringContextUtils.getTypeWithCache(SimpMessagingTemplate.class);
        }
        return template;
    }

    public static Object getRealPayload(SocketMsg msg){
        return msg.getPayload()==null?msg:msg.getPayload();
    }
}
